/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * NewJPanel.java
 *
 * Created on 13/05/2011, 15:02:57
 */
package rdr.xfiles.explorer.gui;

import java.awt.BorderLayout;
import java.io.File;
import javax.swing.JTree;
import rdr.xfiles.explorer.model.FileSystemModel;

/**
 *
 * @author ruanor
 */
public class FileTreeViewPanel extends javax.swing.JPanel {

    JTree tree;
    
    /** Creates new form NewJPanel */
    public FileTreeViewPanel() {
        initComponents();
    }
    
    public void setFileModel(FileSystemModel model)
    {
        tree = new JTree( model ) {       
            @Override
            public String convertValueToText(Object value, boolean selected,
                                             boolean expanded, boolean leaf, int row,
                                             boolean hasFocus) {
                return ((File)value).getName();
            }
        };
        
        tree.setRootVisible( false );
        tree.setShowsRootHandles( true );
        tree.putClientProperty( "JTree.lineStyle", "Angled" );

        tree.revalidate();
        setLayout( new BorderLayout() );
        //add( tree, BorderLayout.CENTER );
        
        jScrollPaneTreeView.add(tree);
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jScrollPaneTreeView = new javax.swing.JScrollPane();

        jScrollPaneTreeView.setName("jScrollTreeView"); // NOI18N

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jScrollPaneTreeView, javax.swing.GroupLayout.DEFAULT_SIZE, 248, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jScrollPaneTreeView, javax.swing.GroupLayout.DEFAULT_SIZE, 300, Short.MAX_VALUE)
        );
    }// </editor-fold>//GEN-END:initComponents
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JScrollPane jScrollPaneTreeView;
    // End of variables declaration//GEN-END:variables
}
